<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品信息编辑</title>
<#include "/WEB-INF/content/module-edit.html">
<link href="${request.contextPath}/res/kindeditor/themes/default/default.css" rel="stylesheet" />
<script charset="utf-8" src="${request.contextPath}/res/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="${request.contextPath}/res/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
var sysStatus = [
    {"id":"0","text":"正常"},
    {"id":"1","text":"禁用"}
];
var oper=[
	{"id":"0","text":"android"},
	{"id":"1","text":"ios"},
	{"id":"2","text":"所有"}
];
var pos=[
	{"id":"0","text":"是"},
   	{"id":"1","text":"否"}
];
var products=[
	<#list map.products as item>
		{"id":"${item.pid}","text":"${item.productname}"}<#if item_has_next>,</#if>
	</#list>
];
var tickets=[
          	<#list map.tickets as item>
          		{"id":"${item.tid}","text":"${item.infoname}"}<#if item_has_next>,</#if>
          	</#list>
          ];
$(function() {
  	$("#os").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
  		data:oper
  	});
  	$("#hascommission").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
  		data:pos
  	});
  	$("#pid").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
  		required:true,
  		data:products  		
  	});
  	$("#ticket").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
  		required:true,
  		data:tickets  		
  	});
  	$('#reducednumber').numberspinner({editable:true,min:0,increment:1 });
  	$("#productprice").numberbox({min:0,precision:2});
  	$("#productshowprice").numberbox({min:0,precision:2});
 });

function mySave(){
	var start=$("#productuptime").datetimebox("getValue");
	var end=$("#productdowntime").datetimebox("getValue");
	if(start&&start.length>0&&end&&end.length>0){
		$.ajax({
			url:"${request.contextPath}/product/sale/validate",
			type:"POST",
			async:false,
			data:{
				pid:$("#pid").combobox("getValue"),
				productuptime:start,
				productdowntime:end
			},
			success:function(data){
				if(data.msg){
					top.showMsg(data.msg);
					return;
				}else{
					save();
				}
			}
		}); 
	}
 }
</script>
<style>
.input-width{
	width: 95%;
}
</style>
 
</head>
<body class="easyui-layout">
	<div region="north" id="toolbar" style="background-color: #eee; padding: 5px; overflow: hidden;" border="false">
		<@auth code="product:sale:create">
			<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-add" style="border: 1px solid #ccc" onclick="javascript:mySave()">保存</a>
		</@auth>
		<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-edit" style="border: 1px solid #ccc" onclick="javascript:cancel()">关闭</a>
	</div>
	<div region="center">
		<div id="p" class="easyui-panel" style="background: #fafafa; padding: 10px" fit="true" toolbar="#toolbar">
			<form id="form" method="post">
				<input type="hidden" id="_id" name="ppid" value="${object.ppid!}"/>
				<table class="form" cellspacing="0" style="width: 100%">
					<tbody style="border: 1px solid #ccc">
						<tr>
							<td class="label">销售商品名称:</td>
							<td><input id="productname" name="productname" class="easyui-validatebox" required="true" value="${object.productname!}"/></td>							
							<td class="validate">*</td>	
							<td class="label">上架商品:</td>
							<td><input id="pid" name="pid" value="${object.pid!}"/></td>							
							<td class="validate">*</td>								
						</tr>					
						<tr>
							<td class="label">绑定票卷:</td>
							<td><input id="ticket" name="ticket" value="${object.ticket!}"/></td>							
							<td class="validate">*</td>	
							<td class="label">上架APP：</td>
							<td><input id="os" name="os" required="true" value="${object.os!'2'}" /></td>
							<td class="validate"></td>				
						</tr>
						<tr>
							<td class="label">上架开始时间：</td>
							<td><input id="productuptime" required="true" name="productuptime" class="easyui-datetimebox" value="${(object.productuptime)!}" editable="false"/></td>
							<td class="validate">*</td>	
							<td class="label">上架结束时间：</td>
							<td><input id="productdowntime" required="true"  name="productdowntime" class="easyui-datetimebox" value="${(object.productdowntime)!}" editable="false"/></td>
							<td class="validate">*</td>															
						</tr>
						<tr>
							<td class="label">折扣价:</td>
							<td><input id="productprice" name="productprice" value="${(object.productprice)!}" class="easyui-validatebox" required="true"/></td>
							<td class="validate">*</td>
							<td class="label">显示价格:</td>
							<td><input id="productshowprice" name="productshowprice" value="${(object.productshowprice)!}" class="easyui-validatebox" required="true"/></td>
							<td class="validate">*</td>
						</tr>					
						<tr>
							<td class="label">是否有佣金：</td>
							<td><input id="hascommission" name="hascommission" value="${object.hascommission!'0'}" /></td>
							<td class="validate"></td>		
							<td class="label">免配送数量：</td>
							<td><input id="reducednumber" name="reducednumber" value="${(object.reducednumber)!}" editable="false"/></td>
							<td class="validate"></td>												
						</tr>
						<tr>
							<td class="label">展示顺序：</td>
							<td><input id="show_order" name="show_order" value="${object.show_order!'0'}" /></td>
							<td class="validate"></td>	
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
</body>
</html>